package practices;

import java.io.File;
import java.util.Scanner;

public class FileNotFoundException extends Throwable {
    public static void readfile(String filePath) throws FileNotFoundExceptionDemo{
        try {
            Scanner sc = new Scanner(new File(filePath));
            while (sc.hasNextLine()) {
                System.out.println(sc.nextLine());
            }
            sc.close();

        } catch (java.io.FileNotFoundException e) {
            throw new RuntimeException(e);
        }

    }
    public static void main(String[] args) {
        try {
            readfile("nonexistent.txt");

        }catch (FileNotFoundExceptionDemo e) {
            System.out.println("错误: " + e.getMessage());
            System.out.println("根本原因: " + e.getCause());
        }
    }
}
